/***********************************************************************
** Copyright (C) 2011 Anthony Naddeo <anthony.naddeo@gmail.com>
**
** This file is part of LinkedUp
**
** LinkedUp is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**
** LinkedUp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this package; If not, see <http://www.gnu.org/licenses/>.
**
***********************************************************************/
import QtQuick 1.1
import com.meego 1.0
import "../components"

MyPage {
	id: root
	width: parent.width; height: parent.height
	title: "Followed Companies"

	tools: ToolBarLayout {
		ToolIcon { platformIconId: "toolbar-view-menu";
			anchors.right: parent===undefined ? undefined : parent.right
			onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
		}
		ToolIcon { platformIconId: "toolbar-back";
			anchors.left: parent===undefined ? undefined : parent.left
			visible: pageStack ? pageStack.depth > 1 ? true : false : false
			onClicked: {
				if(pageStack.depth > 1)
					pageStack.pop()
			}
		}
//		ToolIcon{
//			platformIconId: "toolbar-search"
//			anchors.centerIn: parent
//			onClicked: searchSheet.status == DialogStatus.Open ? searchSheet.close() : searchSheet.open()
//		}

	}

	onGetFinished: model.xml = responseText
	Component.onCompleted: get(API.get_company_following(pagedList.start, pagedList.count))

	FollowingModel{
		id: model
	}

	PagedList{
		id: pagedList
		anchors.topMargin: borderHeight
		pageQuery: "/companies"
		contentModel: model
		contentDelegate: FollowingDelegate{}
		onStartChanged: root.get(API.get_company_following(start, count))

	}
}
